<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
	<title>01-高亮用户的输入</title>
	<style type="text/css">
	* {
		padding: 0;
		margin: 0;
	}
	span.red{
		color: red;
	}
    </style>
</head>
<body>
	<div class="container" id="container">
		<h1>01-高亮用户的输入</h1>
		<div id="content">houdunren.com</div>
		<div>www.houdunren.com</div>
	</div>
	<script type="text/javascript">
	// dun\w+\.
	var prompt = window.prompt('请输入搜索字符串,支持正则', 'dun')
	var reg = new RegExp(prompt, 'g')
	console.log(reg)
	
	var html = container.innerHTML
	console.log(html.match(reg))
	
	var replace = html.replace(reg, function($0) {
		return `<span class="red">${$0}</span>`
	})
	console.log(replace)
	container.innerHTML = replace
	</script>
</body>
</html>